import os
from src.base import bera

# 生成 pom.xml 文件
def generate_pom_file(templates, output_folder='artifacts/miaoma/springboot'):
    pom_code = templates.get_template('springboot/pom.xml.j2').render(
        package_name='com.hainei.beracode',  # 设置 groupId
        project_name='manager',              # 设置 artifactId
        project_version='0.0.1-SNAPSHOT',    # 设置版本号
        project_description='Manager of BeraCode',
        spring_boot_version='3.3.1',
        java_version='17',
        aspectj_version='1.9.7',
        mybatis_plus_version='3.5.7',
        mysql_version='8.0.33',
        lombok_version='1.18.26',
        zxing_version='3.4.1',
        jbcrypt_version='0.4',
        springdoc_openapi_version='2.0.4'
    )

    os.makedirs(output_folder, exist_ok=True)

    pom_file_path = os.path.join(output_folder, 'pom.xml')
    with open(pom_file_path, 'w') as f:
        f.write(pom_code)
    bera.logger.info(f"Generated POM file at: {pom_file_path}")
